<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // let whereThis = () => {
      //   console.log(this);
      // };
      // whereThis.call(123);
      /* let whereThis = function () {
        console.log(this);
      };
      whereThis.call(123);
      function forEach(arr, callback, thisArg) {
        for (let i = 0; i < arr.length; i++) {
          callback.call(thisArg, arr[i], i, arr);
        }
      }
      forEach(
        [1, 5, 7],
        function (e, i, arr) {
          console.log(this);
        },
        [2, 3, 4]
      );
      [1, 2, 3].forEach(
        function (e, i) {
          console.log(e + this[i]);
        },
        [4, 5, 6]
      );
      let arr1 = [1, 2, 3].map(
        function (e, i) {
          return e * this[i];
        },
        [7, 8, 4]
      );
      console.log(arr1); */
      /* let { num: IDnum } = { age: 17, num: 17113212 };
      console.log(IDnum);
      let strs = "bdfca";
      let word = strs.split("").sort().join("");
      console.log(word); */
      let nums = [5, 3, 2, 1, 6, 4];
      let k = 2;
      for (let i = nums.length - 1; i >= nums.length - k; i--) {
        for (let j = 0; j < i; j++) {
          if (nums[j] > nums[j + 1]) {
            [nums[j], nums[j + 1]] = [nums[j + 1], nums[j]];
          }
          console.log(nums);
        }
      }
      console.log(nums);
    </script>
  </body>
</html>
